package com.yida.gwj.deposit.service.impl;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yida.common.core.constant.SecurityConstants;
import com.yida.common.core.domain.R;
import com.yida.common.core.exception.ServiceException;
import com.yida.common.core.text.Convert;
import com.yida.common.core.utils.DateUtils;
import com.yida.common.core.utils.PageUtils;
import com.yida.common.core.utils.StringUtils;
import com.yida.common.security.utils.SecurityUtils;
import com.yida.gwj.api.domain.GwjConfStep;
import com.yida.gwj.api.domain.GwjFinanceAccountMain;
import com.yida.gwj.api.domain.request.RemoteGwjFinanceAccountDetailRequest;
import com.yida.gwj.api.domain.request.RemoteGwjFinanceAccountMainRequest;
import com.yida.gwj.api.service.RemoteGwjConfigService;
import com.yida.gwj.api.service.RemoteGwjFinanceService;
import com.yida.gwj.common.constant.GwjConstants;
import com.yida.gwj.common.domain.GwjBaseBuild;
import com.yida.gwj.common.domain.GwjBaseBusinessHouse;
import com.yida.gwj.common.domain.GwjBaseCommunity;
import com.yida.gwj.common.domain.GwjBaseHouse;
import com.yida.gwj.common.domain.GwjBaseOwner;
import com.yida.gwj.common.domain.dto.GwjUserDTO;
import com.yida.gwj.common.enums.GwjBusinessFlagType;
import com.yida.gwj.common.enums.GwjBusinessStatus;
import com.yida.gwj.common.enums.GwjCheckAccountStatus;
import com.yida.gwj.common.enums.GwjCheckAccountType;
import com.yida.gwj.common.service.IGwjBaseBuildService;
import com.yida.gwj.common.service.IGwjBaseBusinessNumService;
import com.yida.gwj.common.service.IGwjBaseCommunityService;
import com.yida.gwj.common.service.IGwjBaseHouseService;
import com.yida.gwj.common.service.IGwjBaseOwnerService;
import com.yida.gwj.common.utils.GwjConvertUtil;
import com.yida.gwj.deposit.domain.GwjDepositBusiness;
import com.yida.gwj.deposit.domain.GwjDepositBusinessBuild;
import com.yida.gwj.deposit.domain.GwjDepositBusinessCommunity;
import com.yida.gwj.deposit.domain.GwjDepositBusinessDetail;
import com.yida.gwj.deposit.domain.GwjDepositBusinessHouse;
import com.yida.gwj.deposit.domain.GwjDepositBusinessLog;
import com.yida.gwj.deposit.domain.GwjDepositBusinessMoney;
import com.yida.gwj.deposit.domain.GwjDepositBusinessOwner;
import com.yida.gwj.deposit.domain.dto.GwjDepositPageDTO;
import com.yida.gwj.deposit.domain.dto.GwjFinanceAccountDetailsDTO;
import com.yida.gwj.deposit.domain.dto.refund.GwjRefundCompleteBuildDetailDTO;
import com.yida.gwj.deposit.domain.dto.refund.GwjRefundCompleteCommunityDetailDTO;
import com.yida.gwj.deposit.domain.dto.refund.GwjRefundCompleteHouseDetailDTO;
import com.yida.gwj.deposit.domain.dto.refund.GwjRefundCompleteMoneyDTO;
import com.yida.gwj.deposit.domain.dto.refund.GwjRefundCompleteMoneyDetailDTO;
import com.yida.gwj.deposit.domain.request.GwjDepositBusinessBuildRequest;
import com.yida.gwj.deposit.domain.request.GwjDepositBusinessLogRequest;
import com.yida.gwj.deposit.domain.request.refund.GwjRefundCompleteBuildRequest;
import com.yida.gwj.deposit.domain.request.refund.GwjRefundCompleteBusinessQueryRequest;
import com.yida.gwj.deposit.domain.request.refund.GwjRefundCompleteBusinessRequest;
import com.yida.gwj.deposit.domain.request.refund.GwjRefundCompleteCommunityRequest;
import com.yida.gwj.deposit.domain.request.refund.GwjRefundCompleteDelBuildRequest;
import com.yida.gwj.deposit.domain.request.refund.GwjRefundCompleteDelHouseRequest;
import com.yida.gwj.deposit.domain.request.refund.GwjRefundCompleteDetailRequest;
import com.yida.gwj.deposit.domain.request.refund.GwjRefundCompleteHouseRequest;
import com.yida.gwj.deposit.domain.request.refund.GwjRefundCompleteImportBuildsRequest;
import com.yida.gwj.deposit.domain.request.refund.GwjRefundCompleteImportHousesRequest;
import com.yida.gwj.deposit.domain.request.refund.GwjRefundCompleteMoneyRequest;
import com.yida.gwj.deposit.domain.request.refund.GwjRefundCompleteSaveSubmitRequest;
import com.yida.gwj.deposit.enums.GwjDepositBusinessBizTypeEnum;
import com.yida.gwj.deposit.enums.GwjRefundCompleteStepEnum;
import com.yida.gwj.deposit.mapper.GwjDepositBusinessMapper;
import com.yida.gwj.deposit.service.IGwjDepositBusinessBuildService;
import com.yida.gwj.deposit.service.IGwjDepositBusinessCommunityService;
import com.yida.gwj.deposit.service.IGwjDepositBusinessDetailService;
import com.yida.gwj.deposit.service.IGwjDepositBusinessHouseService;
import com.yida.gwj.deposit.service.IGwjDepositBusinessLogService;
import com.yida.gwj.deposit.service.IGwjDepositBusinessMoneyService;
import com.yida.gwj.deposit.service.IGwjDepositBusinessOwnerService;
import com.yida.gwj.deposit.service.IGwjDepositBusinessService;
import com.yida.gwj.deposit.service.IGwjRefundCompleteBusinessService;
import com.yida.gwj.deposit.util.GwjDepositConstants;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;

/**
 * @Author: PPV
 * @Date: 2023-02-13
 */

@Service
public class GwjRefundCompleteBusinessServiceImpl implements IGwjRefundCompleteBusinessService {

    @Resource
    private RemoteGwjConfigService remoteGwjConfigService;

    @Resource
    private RemoteGwjFinanceService remoteGwjFinanceService;

    @Resource
    private IGwjBaseBusinessNumService numService;

    @Resource
    private GwjDepositBusinessMapper businessMapper;

    @Resource
    private IGwjDepositBusinessService businessService;

    @Resource
    private IGwjBaseCommunityService baseCommunityService;

    @Resource
    private IGwjDepositBusinessCommunityService communityService;

    @Resource
    private IGwjBaseBuildService baseBuildService;

    @Resource
    private IGwjDepositBusinessBuildService buildService;

    @Resource
    private IGwjBaseHouseService baseHouseService;

    @Resource
    private IGwjDepositBusinessHouseService houseService;

    @Resource
    private IGwjDepositBusinessMoneyService moneyService;

    @Resource
    private IGwjDepositBusinessDetailService detailService;

    @Resource
    private IGwjBaseOwnerService baseOwnerService;

    @Resource
    private IGwjDepositBusinessOwnerService ownerService;

    @Resource
    private IGwjDepositBusinessLogService logService;

    @Override
    public GwjRefundCompleteMoneyDTO getMoneyInfo(Long bizId) {
        GwjDepositBusinessMoney money = moneyService.selectGwjDepositBusinessMoneyByBizId(bizId);
        if (ObjectUtil.isEmpty(money)) {
            throw new ServiceException("未查到对应的缴费信息");
        }
        GwjRefundCompleteMoneyDTO dto = BeanUtil.copyProperties(money, GwjRefundCompleteMoneyDTO.class);
        // 查询缴费详情集合
        List<GwjDepositBusinessDetail> details = detailService.selectGwjDepositBusinessDetailByBizId(bizId);
        dto.setMoneyDetailDTOList(CollUtil.isNotEmpty(details) ? details.stream().map(item -> BeanUtil.copyProperties(item, GwjRefundCompleteMoneyDetailDTO.class)).collect(Collectors.toList()) : Collections.emptyList());
        return dto;
    }

    @Override
    public GwjRefundCompleteCommunityDetailDTO getCommunityInfo(Long bizId) {
        GwjRefundCompleteCommunityDetailDTO dto = new GwjRefundCompleteCommunityDetailDTO();
        GwjDepositBusinessCommunity community = communityService.selectGwjDepositBusinessCommunityByBizId(bizId);
        if (ObjectUtil.isNotEmpty(community)) {
            List<GwjRefundCompleteBuildDetailDTO> buildDetailDTOList = buildService.selectGwjDepositBusinessBuildListByBizId(bizId).stream().map(item -> {
                GwjRefundCompleteBuildDetailDTO buildDetailDTO = BeanUtil.copyProperties(item, GwjRefundCompleteBuildDetailDTO.class);
                // 查询业务楼栋下所有房屋及业主信息
                List<GwjRefundCompleteHouseDetailDTO> houseDetailDTOList = houseService.listBizHouseDTO(bizId, item.getBuildCode()).stream().map(house -> BeanUtil.copyProperties(house, GwjRefundCompleteHouseDetailDTO.class)).collect(Collectors.toList());
                buildDetailDTO.setHouseDetailDTOList(houseDetailDTOList);
                return buildDetailDTO;
            }).collect(Collectors.toList());
            BeanUtil.copyProperties(community, dto);
            dto.setBuildDetailDTOList(buildDetailDTOList);
        }
        return dto;
    }

    @Override
    public void importCommunity(GwjRefundCompleteCommunityRequest request) {
        // 权限校验
        businessService.checkPermission(request.getBizId());
        // 删除业务小区
        businessService.deleteCommunityBuildHouseOwnerData(request.getBizId());
        // 插入新小区
        GwjBaseCommunity gwjBaseCommunity = baseCommunityService.selectGwjBaseCommunityByGwjBaseCommunityId(request.getCommunityId());
        if (ObjectUtil.isEmpty(gwjBaseCommunity)) {
            throw new ServiceException("查无相关小区信息");
        }
        GwjDepositBusinessCommunity businessCommunity = BeanUtil.copyProperties(gwjBaseCommunity, GwjDepositBusinessCommunity.class);
        businessCommunity.setBizId(request.getBizId());
        communityService.insertGwjDepositBusinessCommunity(businessCommunity);
        // 更新业务金额
        GwjDepositBusinessMoney businessMoney = moneyService.selectGwjDepositBusinessMoneyByBizId(request.getBizId());
        businessMoney.setTotalMoney(new BigDecimal("0.00"));
        moneyService.updateGwjDepositBusinessMoney(businessMoney);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delBuild(GwjRefundCompleteDelBuildRequest delBuildRequest) {
        // 业务权限校验
        GwjDepositBusiness business = businessService.checkPermission(delBuildRequest.getBizId());
        List<GwjDepositBusinessBuild> builds = buildService.selectGwjDepositBusinessBuildListByBizId(delBuildRequest.getBizId());
        if (CollUtil.isEmpty(builds) || builds.size() == 1) {
            throw new ServiceException("最后一个楼栋信息，不能进行删除！");
        }

        // 删除业务楼栋
        GwjDepositBusinessBuild build = buildService.selectGwjDepositBusinessBuildByBizBuildId(delBuildRequest.getBizBuildId());
        buildService.deleteGwjDepositBusinessBuildByBizBuildId(delBuildRequest.getBizBuildId());

        // 删除业务楼栋下所有房屋
        Long[] bizHouseIds = houseService.selectGwjDepositBusinessHouseListByBizIdAndBuildCode(delBuildRequest.getBizId(), build.getBuildCode()).stream().map(GwjBaseBusinessHouse::getBizHouseId).toArray(Long[]::new);
        if (ObjectUtil.isNotEmpty(bizHouseIds)) {
            houseService.deleteGwjDepositBusinessHouseByBizHouseIds(bizHouseIds);
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Long saveBusiness(GwjRefundCompleteSaveSubmitRequest saveSubmitRequest) {
        GwjRefundCompleteBusinessRequest businessRequest = saveSubmitRequest.getBusiness();
        GwjRefundCompleteCommunityRequest communityRequest = saveSubmitRequest.getBusinessCommunity();
        List<GwjRefundCompleteBuildRequest> buildRequests = saveSubmitRequest.getBusinessBuilds();
        List<GwjRefundCompleteHouseRequest> houseRequests = saveSubmitRequest.getBusinessHouses();
        GwjRefundCompleteMoneyRequest moneyRequest = saveSubmitRequest.getBusinessMoney();

        // 查询基础数据
        GwjBaseCommunity gwjBaseCommunity = baseCommunityService.selectGwjBaseCommunityByGwjBaseCommunityId(communityRequest.getCommunityId());
        List<GwjBaseBuild> gwjBaseBuilds = baseBuildService.selectGwjBaseBuildByBuildIdList(buildRequests.stream().map(GwjRefundCompleteBuildRequest::getBuildId).toArray(Long[]::new));
        List<GwjBaseHouse> gwjBaseHouses = baseHouseService.selectGwjBaseHoseByHouseIds(houseRequests.stream().map(GwjRefundCompleteHouseRequest::getHouseId).toArray(Long[]::new));

        String msg = validateCommunityInfo(buildRequests, houseRequests, gwjBaseCommunity, gwjBaseBuilds, gwjBaseHouses);
        if (StrUtil.isNotBlank(msg)) {
            throw new ServiceException(msg);
        }

        // 业务案例处理
        GwjDepositBusiness business = BeanUtil.copyProperties(businessRequest, GwjDepositBusiness.class);
        business.setBizFlagId(GwjBusinessFlagType.REFUND_COMPLETE.getCode());
        Long bizNum = Convert.toLong(numService.getNextNum(business.getAreaId(), business.getBizFlagId()).toString());
        business.setBizNum(bizNum);
        business.setAreaId(gwjBaseCommunity.getAreaId());
        business.setFlowId(remoteGwjConfigService.selectGwjConfBusinessFlagByBizFlagId(business.getBizFlagId(), SecurityConstants.INNER).getData().getFlowId());
        business.setApplicantTime(DateUtils.getNowDate());
        if (businessService.insertGwjDepositBusiness(business) != 1) {
            throw new ServiceException("业务信息保存失败");
        }

        // 业务小区处理
        GwjDepositBusinessCommunity businessCommunity = BeanUtil.copyProperties(gwjBaseCommunity, GwjDepositBusinessCommunity.class);
        businessCommunity.setBizId(business.getBizId());
        communityService.insertGwjDepositBusinessCommunity(businessCommunity);

        // 业务楼栋处理
        List<GwjDepositBusinessBuild> businessBuilds = gwjBaseBuilds.stream().map(item -> {
            GwjDepositBusinessBuild businessBuild = BeanUtil.copyProperties(item, GwjDepositBusinessBuild.class);
            businessBuild.setBizId(business.getBizId());
            businessBuild.setBizCommunityId(businessCommunity.getBizCommunityId());
            return businessBuild;
        }).collect(Collectors.toList());
        buildService.insertGwjDepositBusinessBuilds(businessBuilds);

        // 业务房屋处理
        List<GwjDepositBusinessHouse> businessHouses = gwjBaseHouses.stream().map(item -> {
            GwjDepositBusinessHouse businessHouse = BeanUtil.copyProperties(item, GwjDepositBusinessHouse.class);
            businessHouse.setBizId(business.getBizId());
            return businessHouse;
        }).collect(Collectors.toList());
        houseService.insertGwjDepositBusinessHouses(businessHouses);

        // 业务业主处理
        String[] houseCodes = businessHouses.stream().map(GwjBaseBusinessHouse::getHouseCode).toArray(String[]::new);
        List<GwjBaseOwner> owners = baseOwnerService.selectGwjBaseListByGwjBaseHouseCodes(houseCodes, businessCommunity.getAreaId());
        List<GwjDepositBusinessOwner> depositBusinessOwners = owners.stream().map(item -> {
            GwjDepositBusinessOwner depositBusinessOwner = BeanUtil.copyProperties(item, GwjDepositBusinessOwner.class);
            depositBusinessOwner.setBizId(business.getBizId());
            return depositBusinessOwner;
        }).collect(Collectors.toList());
        ownerService.saveBatch(depositBusinessOwners);

        // 业务金额处理
        GwjDepositBusinessMoney businessMoney = BeanUtil.copyProperties(moneyRequest, GwjDepositBusinessMoney.class);
        businessMoney.setBizId(business.getBizId());
        businessMoney.setAreaId(businessCommunity.getAreaId());
        businessMoney.setTotalMoney(businessMoney.getRefundCompleteMoney().multiply(Convert.toBigDecimal(houseRequests.size())).setScale(2, BigDecimal.ROUND_HALF_UP));
        moneyService.insertGwjDepositBusinessMoney(businessMoney);

        // 记录日志
        logService.addSaveLog(business);
        return business.getBizId();
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateBusiness(GwjRefundCompleteSaveSubmitRequest saveSubmitRequest) {
        GwjRefundCompleteBusinessRequest businessRequest = saveSubmitRequest.getBusiness();
        GwjRefundCompleteCommunityRequest communityRequest = saveSubmitRequest.getBusinessCommunity();
        List<GwjRefundCompleteBuildRequest> buildRequests = saveSubmitRequest.getBusinessBuilds();
        List<GwjRefundCompleteHouseRequest> houseRequests = saveSubmitRequest.getBusinessHouses();
        GwjRefundCompleteMoneyRequest moneyRequest = saveSubmitRequest.getBusinessMoney();
        List<GwjRefundCompleteDetailRequest> detailRequests = saveSubmitRequest.getBusinessDetails();

        // 校验当前账号权限 查询缴费信息
        GwjDepositBusiness business = businessService.checkPermission(businessRequest.getBizId());
        GwjDepositBusinessMoney businessMoney = moneyService.selectGwjDepositBusinessMoneyByBizId(businessRequest.getBizId());
        // 20240227 临时增加判断当前是否是受理阶段，受理阶段对业务数据信息进行修改 start
        if (business.getStepId() == GwjRefundCompleteStepEnum.ACCEPTED.getCode()) {
            // 修改对应的业务信息
            business.setBizName(businessRequest.getBizName());
            business.setApplicantName(businessRequest.getApplicantName());
            business.setPhone(businessRequest.getPhone());
            business.setUpdateBy(SecurityUtils.getUsername());
            business.setUpdateTime(DateUtils.getNowDate());
            // 修改业务数据
            businessService.updateGwjDepositBusiness(business);
            // 修改缴存信息
            businessMoney.setBizType(moneyRequest.getBizType());
            businessMoney.setReason(moneyRequest.getReason());
            businessMoney.setRefundCompleteMoney(moneyRequest.getRefundCompleteMoney());
            moneyService.updateGwjDepositBusinessMoney(businessMoney);
        }
        // 20240227 end
        // 初审步骤 更新缴费明细处理
        GwjConfStep nextStep = remoteGwjConfigService.selectNextGwjConfStepByFlagId(GwjBusinessFlagType.REFUND_COMPLETE.getCode(), business.getStepId(), SecurityConstants.INNER).getData();

        if (nextStep.getStepId().equals(GwjRefundCompleteStepEnum.TRIAL.getCode())) {
            // 查询并校验基础数据
            GwjBaseCommunity gwjBaseCommunity = baseCommunityService.selectGwjBaseCommunityByGwjBaseCommunityId(communityRequest.getCommunityId());
            List<GwjBaseBuild> gwjBaseBuilds = baseBuildService.selectGwjBaseBuildByBuildIdList(buildRequests.stream().map(GwjRefundCompleteBuildRequest::getBuildId).toArray(Long[]::new));
            List<GwjBaseHouse> gwjBaseHouses = baseHouseService.selectGwjBaseHoseByHouseIds(houseRequests.stream().map(GwjRefundCompleteHouseRequest::getHouseId).toArray(Long[]::new));
            List<GwjDepositBusinessHouse> businessHouses = houseService.selectGwjDepositBusinessHouseListByBizId(business.getBizId());
            String msg = validateCommunityInfo(buildRequests, houseRequests, gwjBaseCommunity, gwjBaseBuilds, gwjBaseHouses);
            if (StrUtil.isNotBlank(msg)) {
                throw new ServiceException(msg);
            }

            // 更新案例信息
            business.setStatus(GwjBusinessStatus.NORMAL.getCode());
            businessService.updateGwjDepositBusiness(business);

            // 更新缴存信息
            BeanUtil.copyProperties(moneyRequest, businessMoney);
            businessMoney.setTotalMoney(businessMoney.getRefundCompleteMoney().multiply(Convert.toBigDecimal(businessHouses.size())).setScale(2, BigDecimal.ROUND_HALF_UP));
            moneyService.updateGwjDepositBusinessMoney(businessMoney);
        }

        if (nextStep.getStepId().equals(GwjRefundCompleteStepEnum.FINANCIAL_RECONCILIATION.getCode())) {
            String msg = validateMoneyDetail(detailRequests);
            if (ObjectUtil.isNotEmpty(msg)) {
                throw new ServiceException(msg);
            }
            // 删除原有缴费明细
            Long[] detailIds = detailService.selectGwjDepositBusinessDetailByBizId(business.getBizId()).stream().map(GwjDepositBusinessDetail::getDepositDetailId).toArray(Long[]::new);
            if (ObjectUtil.isNotEmpty(detailIds)) {
                detailService.deleteGwjDepositBusinessDetailByDepositDetailIds(detailIds);
            }
            // 新增缴费明细
            BigDecimal factMoney = new BigDecimal("0.00");
            List<GwjDepositBusinessDetail> businessDetails = detailRequests.stream().map(item -> {
                GwjDepositBusinessDetail businessDetail = BeanUtil.copyProperties(item, GwjDepositBusinessDetail.class);
                businessDetail.setBizId(business.getBizId());
                businessDetail.setBizNum(business.getBizNum());
                businessDetail.setMoneyId(businessMoney.getBizMoneyId());
                businessDetail.setCreateBy(SecurityUtils.getUserId().toString());
                factMoney.add(item.getRefundCompleteMoney());
                return businessDetail;
            }).collect(Collectors.toList());
            detailService.insertBatchGwjDepositBusinessDetail(businessDetails);

            // 更新实缴
            businessMoney.setFactMoney(factMoney);
            moneyService.updateGwjDepositBusinessMoney(businessMoney);
        }

        // 记录日志
        logService.addSaveLog(business);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void submitBusiness(GwjRefundCompleteSaveSubmitRequest saveSubmitRequest) {
        GwjRefundCompleteBusinessRequest businessRequest = saveSubmitRequest.getBusiness();
        GwjDepositBusinessLog businessLog = saveSubmitRequest.getBusinessLog();

        // 校验当前账号权限
        if (ObjectUtil.isEmpty(businessRequest.getBizId())) {
            throw new ServiceException("请先保存业务");
        }
        GwjDepositBusiness business = businessService.checkPermission(businessRequest.getBizId());

        // 查询业务数据
        List<GwjDepositBusinessHouse> businessHouses = houseService.selectGwjDepositBusinessHouseListByBizId(business.getBizId());
        GwjDepositBusinessMoney businessMoney = moneyService.selectGwjDepositBusinessMoneyByBizId(business.getBizId());

        // 判断是否可以直接提交
        if (ObjectUtil.isNull(communityService.selectGwjDepositBusinessCommunityListByBizId(business.getBizId()))) {
            throw new ServiceException("小区信息不能为空");
        }
        if (ObjectUtil.isEmpty(buildService.selectGwjDepositBusinessBuildListByBizId(business.getBizId()))) {
            throw new ServiceException("小区楼栋不能为空");
        }
        if (ObjectUtil.isEmpty(businessHouses)) {
            throw new ServiceException("小区房屋不能为空");
        }
        if (ObjectUtil.isEmpty(businessMoney)) {
            throw new ServiceException("缴存信息不能为空");
        }

        // 设置日志流程步骤,业务编号
        businessLog.setBizId(business.getBizId());
        businessLog.setStepId(business.getStepId());

        // 获取当前步骤所有配置
        List<String> configs = remoteGwjConfigService.selectGwjConfStepConfigInfoCodeListByBizFlagId(business.getStepId(), SecurityConstants.INNER).getData();
        // 判断当前是否需要收件人
        if (CollUtil.contains(configs, GwjDepositConstants.SUBMIT_CHOOSE_USER) && StringUtils.isAnyBlank(Convert.toStr(businessLog.getUserId()), businessLog.getRealName())) {
            throw new ServiceException("请选择下一位收件人");
        }

        // 当前办理人员
        business.setCurrentOperId(ObjectUtil.isNotEmpty(businessLog.getUserId()) ? businessLog.getUserId() : SecurityUtils.getUserId());
        business.setCurrentOperName(StrUtil.isNotBlank(businessLog.getRealName()) ? businessLog.getRealName() : SecurityUtils.getLoginUser().getSysUser().getRealName());

        // 校验步骤参数
        GwjConfStep nextStep = remoteGwjConfigService.selectNextGwjConfStepByFlagId(GwjBusinessFlagType.REFUND_COMPLETE.getCode(), business.getStepId(), SecurityConstants.INNER).getData();
        if (ObjectUtil.isNull(nextStep)) {
            throw new ServiceException("当前业务已完结");
        }
        switch (GwjRefundCompleteStepEnum.getByStepId(nextStep.getStepId())) {
            case FINANCIAL_RECONCILIATION:
                // 缴费详情
                if (ObjectUtil.isEmpty(detailService.selectGwjDepositBusinessDetailByBizId(business.getBizId()))) {
                    throw new ServiceException("缴费详情不能为空");
                }
                // 总账流水
                if (ObjectUtil.isEmpty(remoteGwjFinanceService.selectGwjFinanceAccountMainList(new GwjFinanceAccountMain() {
                    {
                        setBizId(business.getBizId());
                    }
                }, SecurityConstants.INNER).getData())) {
                    throw new ServiceException("未生成流水，请先生成流水");
                }
                // 分类账流水
                if (ObjectUtil.isEmpty(remoteGwjFinanceService.selectGwjFinanceAccountDetailListByBizId(business.getBizId(), SecurityConstants.INNER).getData())) {
                    throw new ServiceException("未生成流水，请先生成流水");
                }
                break;
            case CASE_REVIEW:
                if (!businessMoney.getStatus().equals(GwjCheckAccountStatus.CHECK_SUCCESS.getCode())) {
                    throw new ServiceException("财务还未对账，请先进行财务对账");
                }
                break;
            default:
                break;
        }

        business.setStepId(nextStep.getStepId());

        // 更新业务
        business.setStatus(GwjBusinessStatus.NORMAL.getCode());
        businessService.updateGwjDepositBusiness(business);

        // 记录日志
        logService.addSubmitLog(businessLog, business);

        // 步骤结束 更新基础数据
        if (ObjectUtil.isEmpty(remoteGwjConfigService.selectNextGwjConfStepByFlagId(GwjBusinessFlagType.REFUND_COMPLETE.getCode(), business.getStepId(), SecurityConstants.INNER).getData())) {

            // 更新基础房屋
            List<GwjBaseHouse> gwjBaseHouses = baseHouseService.selectGwjBaseHoseByHouseIds(businessHouses.stream().map(GwjDepositBusinessHouse::getHouseId).toArray(Long[]::new));
            gwjBaseHouses = gwjBaseHouses.stream().map(item -> {
                GwjDepositBusinessBizTypeEnum bizTypeEnum = GwjDepositBusinessBizTypeEnum.getByCode(businessMoney.getBizType());
                // 余额、缴存 同增同减
                if (bizTypeEnum == GwjDepositBusinessBizTypeEnum.REFUND) {
                    item.setCurrentMoney(item.getCurrentMoney().subtract(businessMoney.getRefundCompleteMoney()));
                    item.setDepositMoney(item.getDepositMoney().subtract(businessMoney.getRefundCompleteMoney()));
                } else {
                    item.setCurrentMoney(item.getCurrentMoney().add(businessMoney.getRefundCompleteMoney()));
                    item.setDepositMoney(item.getDepositMoney().add(businessMoney.getRefundCompleteMoney()));
                }
                return item;
            }).collect(Collectors.toList());
            gwjBaseHouses.forEach(item -> {
                baseHouseService.updateGwjBaseHouse(item);
            });

            // 更新业务
            business.setStatus(GwjBusinessStatus.FINISH.getCode());
            businessService.updateGwjDepositBusiness(business);
            logService.addFinishLog(business);
        }

    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteBusinessData(Long bizId) {
        // 权限校验
        GwjDepositBusiness business = businessService.checkPermission(bizId);
        // 只有受理阶段可以删页
        GwjConfStep nextStep = remoteGwjConfigService.selectNextGwjConfStepByFlagId(business.getBizFlagId(), business.getStepId(), SecurityConstants.INNER).getData();
        if (GwjRefundCompleteStepEnum.getByStepId(nextStep.getStepId()) != GwjRefundCompleteStepEnum.TRIAL) {
            throw new ServiceException("当前办事员没有权限操作本业务!");
        }

        // 清空业务信息
        business.setApplicantName("");
        business.setPhone("");
        business.setBizName("");
        business.setCommentFlag(GwjConstants.NO);
        business.setStatus(GwjBusinessStatus.NORMAL.getCode());
        business.setApplicantTime(DateUtils.getNowDate());
        businessService.updateGwjDepositBusiness(business);

        // 清空业务小区信息
        businessService.deleteCommunityBuildHouseOwnerData(bizId);

        // 清空业务金额信息
        GwjDepositBusinessMoney money = moneyService.selectGwjDepositBusinessMoneyByBizId(bizId);
        BigDecimal zero = new BigDecimal("0.00");
        money.setTotalSize(zero);
        money.setRefundCompleteMoney(zero);
        money.setBizType(GwjDepositBusinessBizTypeEnum.REFUND.getCode());
        money.setTotalMoney(zero);
        money.setReason("");
        moneyService.updateGwjDepositBusinessMoney(money);
        //// 删除总账流水
        // if (ObjectUtil.isNotEmpty(remoteGwjFinanceService.selectGwjFinanceAccountMainByBizId(bizId,
        //// SecurityConstants.INNER).getData())) {
        // remoteGwjFinanceService.deleteGwjFinanceAccountMainByBizId(bizId, SecurityConstants.INNER);
        // }
        //// 删除分账流水
        // if (CollUtil.isNotEmpty(remoteGwjConfigService.selectGwjConfStepConfigInfoCodeListByBizFlagId(bizId,
        //// SecurityConstants.INNER).getData())) {
        // remoteGwjFinanceService.deleteGwjFinanceAccountDetailByBizId(bizId, SecurityConstants.INNER);
        // }
        // 删除日志
        logService.deleteGwjDepositBusinessLogByBizId(bizId);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void genFinancialStatement(Long bizId) {
        // 验证用户是否拥有操作权限
        businessService.checkPermission(bizId);
        // 重置总账、分账流水
        if (!businessService.removeLedger(bizId)) {
            throw new ServiceException("总账、分账流水重置失败");
        }
        // 生成总账、分账流水
        if (!businessService.generateLedger(bizId)) {
            throw new ServiceException("生成总账、分账流水失败");
        }
    }

    @Override
    public void financeCheck(Long bizId) {
        // 权限校验
        businessService.checkPermission(bizId);
        GwjDepositBusinessMoney money = moneyService.selectGwjDepositBusinessMoneyByBizId(bizId);
        List<GwjDepositBusinessDetail> details = detailService.selectGwjDepositBusinessDetailByBizId(bizId);
        if (ObjectUtil.isEmpty(money)) {
            throw new ServiceException("查无金额数据");
        }
        if (CollUtil.isEmpty(details)) {
            throw new ServiceException("查无对应缴费明细");
        }

        // 校验缴费明细
        BigDecimal factMoney = details.stream().map(GwjDepositBusinessDetail::getRefundCompleteMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
        if (money.getTotalMoney().compareTo(factMoney) != 0) {
            throw new ServiceException("实缴金额与应缴金额不相等！");
        }

        // 更新缴费信息 对账状态
        money.setStatus(GwjCheckAccountStatus.CHECK_SUCCESS.getCode());
        moneyService.updateGwjDepositBusinessMoney(money);

        // 更新总账、分账 对账状态
        if (!businessService.edisLedgerStatus(bizId, money.getStatus())) {
            throw new ServiceException("总账、分账对账状态更新失败");
        }

    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delMoneyDetail(Long bizId, Long depositDetailId) {
        List<GwjDepositBusinessDetail> details = detailService.selectGwjDepositBusinessDetailByBizId(bizId);
        if (ObjectUtil.isEmpty(details) || details.size() == 1) {
            throw new ServiceException("最后一个缴款明细不能删除");
        }
        detailService.deleteGwjDepositBusinessDetailByDepositDetailId(depositDetailId);
        // 删除已生成的流水
        if (ObjectUtil.isNotEmpty(remoteGwjFinanceService.selectGwjFinanceAccountMainByBizId(bizId, SecurityConstants.INNER).getData())) {
            remoteGwjFinanceService.deleteGwjFinanceAccountMainByBizId(bizId, SecurityConstants.INNER);
        }
        // 删除分账流水
        if (CollUtil.isNotEmpty(remoteGwjConfigService.selectGwjConfStepConfigInfoCodeListByBizFlagId(bizId, SecurityConstants.INNER).getData())) {
            remoteGwjFinanceService.deleteGwjFinanceAccountDetailByBizId(bizId, SecurityConstants.INNER);
        }
    }

    @Override
    public void delHouse(GwjRefundCompleteDelHouseRequest delHouseRequest) {
        // 业务权限校验
        GwjDepositBusiness business = businessService.checkPermission(delHouseRequest.getBizId());
        List<GwjDepositBusinessHouse> businessHouses = houseService.selectGwjDepositBusinessHouseListByBizId(delHouseRequest.getBizId());
        if (CollUtil.isEmpty(businessHouses) || businessHouses.size() == 1) {
            throw new ServiceException("最后一个房屋不能删除");
        }
        houseService.deleteGwjDepositBusinessHouseByBizHouseId(delHouseRequest.getBizHouseId());
    }

    @Override
    public List<GwjDepositPageDTO> getPage(GwjRefundCompleteBusinessQueryRequest request) {
        GwjDepositBusiness business = BeanUtil.copyProperties(request, GwjDepositBusiness.class);
        business.setBizFlagId(GwjBusinessFlagType.REFUND_COMPLETE.getCode());
        PageUtils.startPage();
        return businessMapper.selectGwjDepositBusinessPage(business);
    }

    @Override
    public void indexSubmit(GwjDepositBusinessLog businessLog) {
        // 校验业务权限
        GwjDepositBusiness business = businessService.checkPermission(businessLog.getBizId());
        Long bizId = business.getBizId();
        // 构建请求参数
        GwjRefundCompleteSaveSubmitRequest submitRequest = new GwjRefundCompleteSaveSubmitRequest();
        submitRequest.setBusiness(BeanUtil.copyProperties(business, GwjRefundCompleteBusinessRequest.class));
        submitRequest.setBusinessCommunity(BeanUtil.copyProperties(communityService.selectGwjDepositBusinessCommunityByBizId(bizId), GwjRefundCompleteCommunityRequest.class));
        submitRequest.setBusinessBuilds(GwjConvertUtil.convertList(buildService.selectGwjDepositBusinessBuildListByBizId(bizId), GwjRefundCompleteBuildRequest.class));
        submitRequest.setBusinessHouses(GwjConvertUtil.convertList(houseService.selectGwjDepositBusinessHouseListByBizId(bizId), GwjRefundCompleteHouseRequest.class));
        submitRequest.setBusinessMoney(BeanUtil.copyProperties(moneyService.selectGwjDepositBusinessMoneyByBizId(bizId), GwjRefundCompleteMoneyRequest.class));
        submitRequest.setBusinessLog(BeanUtil.copyProperties(businessLog, GwjDepositBusinessLogRequest.class));
        submitRequest.setBusinessDetails(GwjConvertUtil.convertList(detailService.selectGwjDepositBusinessDetailByBizId(bizId), GwjRefundCompleteDetailRequest.class));
        // 提交请求参数
        submitBusiness(submitRequest);
    }

    @Override
    public void importBuilds(GwjRefundCompleteImportBuildsRequest request) {
        // 校验业务权限
        GwjDepositBusiness business = businessService.checkPermission(request.getBizId());

        // 查询业务小区信息、楼栋信息
        GwjDepositBusinessCommunity businessCommunity = communityService.selectGwjDepositBusinessCommunityByBizId(business.getBizId());
        buildService.selectGwjDepositBusinessBuildListByBizId(business.getBizId()).stream().forEach(item -> {
            for (GwjRefundCompleteBuildRequest buildRequest : request.getBuildRequests()) {
                if (buildRequest.getBuildId().equals(item.getBizBuildId())) {
                    throw new ServiceException("请勿重复导入楼栋");
                }
            }
        });

        // 导入新楼栋
        List<GwjBaseBuild> gwjBaseBuilds = baseBuildService.selectGwjBaseBuildListByBuildIds(request.getBuildRequests().stream().map(GwjRefundCompleteBuildRequest::getBuildId).toArray(Long[]::new));
        if (CollUtil.isEmpty(gwjBaseBuilds) || gwjBaseBuilds.size() != request.getBuildRequests().size()) {
            throw new ServiceException("导入的楼栋信息有误，请检查后导入");
        }

        List<GwjDepositBusinessBuild> businessBuilds = gwjBaseBuilds.stream().map(item -> {
            GwjDepositBusinessBuild businessBuild = BeanUtil.copyProperties(item, GwjDepositBusinessBuild.class);
            businessBuild.setBizId(business.getBizId());
            businessBuild.setBizCommunityId(businessCommunity.getBizCommunityId());
            return businessBuild;
        }).collect(Collectors.toList());
        buildService.insertGwjDepositBusinessBuilds(businessBuilds);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void importHouses(GwjRefundCompleteImportHousesRequest request) {
        // 业务权限校验
        GwjDepositBusiness business = businessService.checkPermission(request.getBizId());
        GwjDepositBusinessCommunity businessCommunity = communityService.selectGwjDepositBusinessCommunityByBizId(business.getBizId());
        houseService.selectGwjDepositBusinessHouseListByBizId(business.getBizId()).stream().forEach(item -> {
            for (GwjRefundCompleteHouseRequest houseRequest : request.getHouseRequests()) {
                if (houseRequest.getHouseId().equals(item.getHouseId())) {
                    throw new ServiceException("请勿导入相同的房屋");
                }
            }
        });

        // 导入新房屋
        List<GwjBaseHouse> gwjBaseHouses = baseHouseService.selectGwjBaseHoseByHouseIds(request.getHouseRequests().stream().map(GwjRefundCompleteHouseRequest::getHouseId).toArray(Long[]::new));
        if (CollUtil.isEmpty(gwjBaseHouses) || request.getHouseRequests().size() != gwjBaseHouses.size()) {
            throw new ServiceException("导入房屋信息有误，请检查后导入");
        }
        List<GwjDepositBusinessHouse> businessHouses = gwjBaseHouses.stream().map(item -> {
            GwjDepositBusinessHouse businessHouse = BeanUtil.copyProperties(item, GwjDepositBusinessHouse.class);
            businessHouse.setBizId(business.getBizId());
            return businessHouse;
        }).collect(Collectors.toList());
        houseService.insertGwjDepositBusinessHouses(businessHouses);

        // 导入相关业主
        List<GwjBaseOwner> owners = baseOwnerService.selectGwjBaseListByGwjBaseHouseCodes(businessHouses.stream().map(GwjBaseBusinessHouse::getHouseCode).toArray(String[]::new), businessCommunity.getAreaId());
        List<GwjDepositBusinessOwner> depositBusinessOwners = owners.stream().map(item -> {
            GwjDepositBusinessOwner depositBusinessOwner = BeanUtil.copyProperties(item, GwjDepositBusinessOwner.class);
            depositBusinessOwner.setBizId(business.getBizId());
            return depositBusinessOwner;
        }).collect(Collectors.toList());
        ownerService.saveBatch(depositBusinessOwners);
    }

    @Override
    public List<GwjFinanceAccountMain> selectGwjFinanceAccountMainList(RemoteGwjFinanceAccountMainRequest mainRequest) {
        GwjFinanceAccountMain accountMain = new GwjFinanceAccountMain();
        BeanUtil.copyProperties(mainRequest, accountMain);
        return remoteGwjFinanceService.selectGwjFinanceAccountMainList(accountMain, SecurityConstants.INNER).getData().stream().map(item -> {
            item.setBizFlagIdStr(GwjBusinessFlagType.getInfoByCode(item.getBizFlagId()));
            item.setCheckTypeStr(GwjCheckAccountType.getInfoByCode(item.getCheckType()));
            item.setCheckStatusStr(GwjCheckAccountStatus.getInfoByCode(item.getCheckStatus()));
            return item;
        }).collect(Collectors.toList());
    }

    @Override
    public List<GwjFinanceAccountDetailsDTO> selectGwjFinanceAccountDetailList(RemoteGwjFinanceAccountDetailRequest detailRequest) {
        return remoteGwjFinanceService.getGwjFinanceAccountDetailList(detailRequest, SecurityConstants.INNER).getData().stream().map(item -> {
            GwjFinanceAccountDetailsDTO dto = new GwjFinanceAccountDetailsDTO();
            item.setBizFlagIdStr(GwjBusinessFlagType.getInfoByCode(item.getBizFlagId()));
            item.setCheckTypeStr(GwjCheckAccountType.getInfoByCode(item.getCheckType()));
            item.setCheckStatusStr(GwjCheckAccountStatus.getInfoByCode(item.getCheckStatus()));
            BeanUtil.copyProperties(item, dto);
            String houseLocation = houseService.selectGwjDepositBusinessHouseByHouseCodeAndBizId(item.getHouseCode(), item.getBizId()).getHouseLocation();
            dto.setHoseLocation(houseLocation);
            return dto;
        }).collect(Collectors.toList());
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void fallback(GwjDepositBusinessLog businessLog) {
        // 判断当前用户是否有权限
        GwjDepositBusiness gwjDepositBusiness = businessService.checkPermission(businessLog.getBizId());
        // 查找上一个步骤办理人员
        GwjConfStep step = remoteGwjConfigService.selectPreviousGwjConfStepByFlagId(gwjDepositBusiness.getBizFlagId(), gwjDepositBusiness.getStepId(), SecurityConstants.INNER).getData();
        if (StringUtils.isNull(step)) {
            throw new ServiceException("当前业务步骤是第一步，不能再回退");
        }
        // 设置日志的当前步骤
        businessLog.setStepId(gwjDepositBusiness.getStepId());
        // 设置业务回退的步骤
        gwjDepositBusiness.setStepId(step.getStepId());
        // 修改业务当前办理人员为上一个流程的最终提交人
        GwjUserDTO user = logService.getPreviousSubmitUser(gwjDepositBusiness.getBizId(), step.getStepId());
        gwjDepositBusiness.setCurrentOperId(user.getUserId());
        gwjDepositBusiness.setCurrentOperName(user.getRealName());
        // 设置回退状态
        gwjDepositBusiness.setStatus(GwjBusinessStatus.FALLBACK.getCode());
        businessMapper.updateGwjDepositBusiness(gwjDepositBusiness);
        // 保存回退日志
        businessLog.setRealName(user.getRealName());
        businessLog.setUserId(user.getUserId());

        // 判断时候有缴费明细 注：应要求20230803注释缴存明细删除，改由用户自行操作
        // if (CollUtil.isNotEmpty(detailService.selectGwjDepositBusinessDetailByBizId(gwjDepositBusiness.getBizId())))
        // {
        // detailService.deleteBatchGwjDepositBusinessDetailByBizId(gwjDepositBusiness.getBizId());
        // }

        // 判断业务是否有生成流水
        if (R.isSuccess(remoteGwjFinanceService.selectGwjFinanceAccountMainList(new GwjFinanceAccountMain() {
            {
                setBizId(businessLog.getBizId());
            }
        }, SecurityConstants.INNER))) {
            // 先删除后
            remoteGwjFinanceService.deleteGwjFinanceAccountMainByBizId(businessLog.getBizId(), SecurityConstants.INNER);
        } else {
            throw new ServiceException("回退失败");
        }

        // 判断业务是否有生成分类账流水
        if (R.isSuccess(remoteGwjFinanceService.selectGwjFinanceAccountDetailListByBizId(businessLog.getBizId(), SecurityConstants.INNER))) {
            // 先删除
            remoteGwjFinanceService.deleteGwjFinanceAccountDetailByBizId(businessLog.getBizId(), SecurityConstants.INNER);
        } else {
            throw new ServiceException("回退失败");
        }
        logService.addFallbackLog(businessLog);
    }

    /**
     * 校验缴费明细
     *
     * @param moneyDetails
     */
    private String validateMoneyDetail(List<GwjRefundCompleteDetailRequest> moneyDetails) {
        if (CollUtil.isEmpty(moneyDetails)) {
            return "缴费明细不能为空";
        }
        for (GwjRefundCompleteDetailRequest moneyDetail : moneyDetails) {
            if (StrUtil.isBlank(moneyDetail.getBuildInfo())) {
                return "涉及楼栋不能为空";
            }
            if (ObjectUtil.isEmpty(moneyDetail.getRefundCompleteDate())) {
                return "退补日期不能为空";
            }
            if (ObjectUtil.isEmpty(moneyDetail.getRefundCompleteMoney())) {
                return "退补金额不能为空";
            }
        }
        return "";
    }

    /**
     * 校验小区信息
     *
     * @param buildRequests
     * @param houseRequests
     * @param gwjBaseCommunity
     * @param gwjBaseBuilds
     * @param gwjBaseHouses
     * @return
     */
    private String validateCommunityInfo(List<GwjRefundCompleteBuildRequest> buildRequests, List<GwjRefundCompleteHouseRequest> houseRequests, GwjBaseCommunity gwjBaseCommunity, List<GwjBaseBuild> gwjBaseBuilds, List<GwjBaseHouse> gwjBaseHouses) {
        if (ObjectUtil.isEmpty(gwjBaseCommunity)) {
            return "未查到对应的小区信息";
        }
        if (ObjectUtil.isEmpty(gwjBaseBuilds)) {
            return "未查到对应的楼栋信息";
        }
        if (ObjectUtil.isEmpty(gwjBaseHouses)) {
            return "未查到对应的房屋信息";
        }
        if (gwjBaseBuilds.size() != buildRequests.size()) {
            return "楼栋信息有误，请重新导入";
        }
        return "";
    }

    /**
     * 清空 业务楼栋、房屋、业主信息
     *
     * @param bizId
     */
    private void clearBuildHouseOwnerData(Long bizId) {
        // 删除业务楼栋
        if (StringUtils.isNotEmpty(buildService.selectGwjDepositBusinessBuildListByBizId(bizId))) {
            buildService.deleteGwjDepositBusinessBuildByBizId(bizId);
        }
        // 删除业务房屋
        if (StringUtils.isNotEmpty(houseService.selectGwjDepositBusinessHouseListByBizId(bizId))) {
            houseService.deleteGwjDepositBusinessHouseByBizId(bizId);
        }
        // 删除业务业主
        if (StringUtils.isNotEmpty(ownerService.selectGwjDepositBusinessOwnerListByBizId(bizId))) {
            ownerService.deleteGwjDepositBusinessOwnerByBizId(bizId);
        }
    }

    /**
     * 清空 业务房屋、业主信息
     *
     * @param bizId
     */
    private void clearHouseOwnerData(Long bizId) {
        // 删除业务房屋
        if (StringUtils.isNotEmpty(houseService.selectGwjDepositBusinessHouseListByBizId(bizId))) {
            houseService.deleteGwjDepositBusinessHouseByBizId(bizId);
        }
        // 删除业务业主
        if (StringUtils.isNotEmpty(ownerService.selectGwjDepositBusinessOwnerListByBizId(bizId))) {
            ownerService.deleteGwjDepositBusinessOwnerByBizId(bizId);
        }
    }

    /* 
     * 修改楼栋信息
     */
    @Override
    public void updateBuildInfo(GwjDepositBusinessBuildRequest gdbbr) {
        // 业务楼栋ID编号
        Long bizBuildId = gdbbr.getBizBuildId();
        GwjDepositBusinessBuild gwjDepositBusinessBuild = buildService.selectGwjDepositBusinessBuildByBizBuildId(bizBuildId);
        if (StringUtils.isNull(gwjDepositBusinessBuild)) {
            throw new ServiceException("未查询到对应楼栋信息！");
        }
        GwjDepositBusinessBuild upGwjDepositBusinessBuild = new GwjDepositBusinessBuild() {
            /**
             *
             */
            private static final long serialVersionUID = 1L;

            {
                setBizBuildId(bizBuildId);
                // setBuildName(gdbbr.getBuildName());
                setBuildType(gdbbr.getBuildType());
            }
        };
        buildService.updateGwjDepositBusinessBuild(upGwjDepositBusinessBuild);
    }

}
